package org.jrfe.gfx;

import org.jrfe.JRFE;

/**
 * Blending function object
 * Is used with JRFERenderer.applyBlending()
 * see glBlendFunc for information on parameters
 * src and dest parameter can be fount in {@link JRFE.Blending}
 *  
 * @author Kalvis Freimanis
 */
public class BlendFunc {
	
	/**
	 * Predefine Blending Functions 
	 * with this one Blending is regulated by alpha value in colors of vertexes 
	 */
	public static final BlendFunc SIMPLE = new BlendFunc(JRFE.Blending.Src.SRC_ALPHA,JRFE.Blending.Dest.ONE_MINUS_SRC_ALPHA);
	
	/**
	 * Source factor
	 */
	public int src;
	
	/**
	 * Destination factor
	 */
	public int dest;
	
	/**
	 * Create Blend Functions with default values 
	 * src = JRFE.Blending.Src.ONE;
	 * dest = JRFE.Blending.Dest.ZERO; 
	 */
	public BlendFunc() {
		src = JRFE.Blending.Src.ONE;
		dest = JRFE.Blending.Dest.ZERO;
	}	
	
	/**
	 * Create Blend Functions with user specified values
	 * @param src Blending source factor from {@link JRFE.Blending.Src}
	 * @param dest Blending source factor from {@link JRFE.Blending.Dest}
	 */
	public BlendFunc(int src, int dest) {
		this.src = src;
		this.dest = dest;
	}

	/**
	 * Close This Blend Functions
	 */
	@Override
	public BlendFunc clone() throws CloneNotSupportedException {
		return new BlendFunc(this.src,this.dest);
	}
	
	/**
	 * Test if source factor and destination factor are the same 
	 */
	@Override
	public boolean equals(Object obj) {
		if(obj != null && obj instanceof BlendFunc){
			BlendFunc b = (BlendFunc)obj;
			if(b.src == src && b.dest == dest){
				return true;
			}
			
		}
		return false;
	}
	
}
